*-------------------------------------------------------------------------------*
* SET DIRECTORIES
*-------------------------------------------------------------------------------*
cls
set seed 123
cap log close
graph set window fontface "Times New Roman" 

cd LOCATION // change "LOCATION" to be the directory the unzipped replication package
log using "./replog.log", replace
di "START TIME: $S_TIME" 

local l_direc_data ./data
local l_direc_code ./code
local l_direc_figtab ./figtab
local l_args_direcs `l_direc_data'  `l_direc_code' `l_direc_figtab'


*-------------------------------------------------------------------------------*
* INSTALL ANY NECESSARY PACKAGES
*-------------------------------------------------------------------------------*
foreach l_pckg in egenmore gtools reghdfe estout {
	cap ssc install `l_pckg'
}



*-------------------------------------------------------------------------------*
* BUILD DATA
*-------------------------------------------------------------------------------*
do `l_direc_code'/00a_databuild.do `l_args_direcs'
do `l_direc_code'/00b_databuild_affil.do `l_args_direcs'



*-------------------------------------------------------------------------------*
* SUM STATS
*-------------------------------------------------------------------------------*
do `l_direc_code'/1_sumstats.do `l_args_direcs'



*-------------------------------------------------------------------------------*
* ANALYSES
*-------------------------------------------------------------------------------*
do `l_direc_code'/2_main_binreg.do `l_args_direcs'
do `l_direc_code'/3_het.do `l_args_direcs'
do `l_direc_code'/4_affilreg.do `l_args_direcs'
do `l_direc_code'/5_het_meshagg.do `l_args_direcs'
do `l_direc_code'/6_sim.do `l_args_direcs'
do `l_direc_code'/7_cosineapproach.do `l_args_direcs'



di "END TIME: $S_TIME" 
cap log close
